<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /* 记忆题 */
      var numTrees = function (n) {
        let dp = new Array(n + 1).fill(0)
        dp[0] = dp[1] = 1
        for (let i = 2; i <= n; i++) {
          for (let j = 0; j < i; j++) {
            dp[i] += dp[j] * dp[i - j - 1]
          }
        }
        return dp[n]
      }
    </script>
  </body>
</html>
